package edu.pitt.dbmi.odie.gapp.gwt.client.navigator;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Label;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.layout.HLayout;
import com.smartgwt.client.widgets.layout.HStack;
import com.smartgwt.client.widgets.layout.VStack;

public class ODIE_NavigationPanelEntryPoint implements EntryPoint {

    public void onModuleLoad() {

        HLayout canvas = new HLayout();
        canvas.setIsGroup(true) ;
        canvas.setGroupTitle("Analysis") ;
        canvas.setMembersMargin(20) ;
        canvas.setLayoutMargin(20) ;

        VStack navigationStack = new VStack();
        navigationStack.setShowEdges(true);
        navigationStack.setWidth("30%");
        navigationStack.setHeight100() ;
        navigationStack.setMembersMargin(5);
        navigationStack.setLayoutMargin(10);
        navigationStack.addMember(buildGroup(null, "Documents"));
        navigationStack.addMember(buildGroup(null, "Annotations"));
        canvas.addMember(navigationStack);

        VStack documentViewerStack = new VStack();
        documentViewerStack.setShowEdges(true);
        documentViewerStack.setWidth("70%") ;
        documentViewerStack.setHeight100() ;
        documentViewerStack.setMembersMargin(5);
        documentViewerStack.setLayoutMargin(10);
        documentViewerStack.addMember(buildGroup(null, "Current Document"));
        canvas.addMember(documentViewerStack);

        canvas.draw();
    }
    
    private Canvas buildGroup(ListGrid aListGrid, String groupTitle) {
		VStack group = new VStack();
		group.setMembersMargin(5) ;
		group.setLayoutMargin(10) ;
		group.setIsGroup(true) ;
		group.setGroupTitle(groupTitle);
		if (aListGrid != null) {
			group.addMember(aListGrid);
		}
		else {
			group.addMember(new BlueBox(null, 80, groupTitle)) ;
		}
		
		return group;
	}

    class BlueBox extends Label {

        public BlueBox(String contents) {
            setAlign(Alignment.CENTER);
            setBorder("1px solid #808080");
            setBackgroundColor("lightblue");
            setContents(contents);
        }

        public BlueBox(Integer width, Integer height, String contents) {
            this(contents);
            if (width != null) setWidth(width);
            if (height != null) setHeight(height);
        }
    }

}


